/*
 * @Author: suchen.ma ma_suchen@126.com
 * @Date: 2023-09-25 22:47:02
 * @LastEditors: suchen.ma ma_suchen@126.com
 * @LastEditTime: 2023-10-15 23:33:43
 * @FilePath: \SoftWare\User\APP\InCall_info.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#ifndef __InCall_info__H
#define __InCall_info__H

#ifdef __cplusplus
extern "C"
{
#endif

#include "stdbool.h"
#include "SYS_version.h"

#define led_light 500
    
    
#define protect_time 5000

#pragma pack(1)

    struct type_version
    {
        unsigned char versionL;
        unsigned char versionH;
    };

    /*
     * 版本号的结构体，软件版本号的表示
     */
    typedef union
    {
        unsigned short version_u16;
        struct type_version version;
    } _version;

    typedef struct
    {
        unsigned char bit_door_open : 1;
        unsigned char bit_door_close : 1;
        unsigned char bit_door_hold : 1;
        unsigned char bit_reserve : 5;

        unsigned char bit_floor_1 : 1;
        unsigned char bit_floor_2 : 1;
        unsigned char bit_floor_3 : 1;
        unsigned char bit_floor_4 : 1;
        unsigned char bit_floor_5 : 1;
        unsigned char bit_floor_6 : 1;
        unsigned char bit_floor_7 : 1;
        unsigned char bit_floor_8 : 1;
    } key_board_status_s_t;

    typedef struct
    {

        /***********************/
        unsigned char bit_door_open : 1;
        unsigned char bit_door_close : 1;
        unsigned char bit_door_hold : 1;
        unsigned char bit_reserve : 5;

        unsigned char bit_floor_1 : 1;
        unsigned char bit_floor_2 : 1;
        unsigned char bit_floor_3 : 1;
        unsigned char bit_floor_4 : 1;
        unsigned char bit_floor_5 : 1;
        unsigned char bit_floor_6 : 1;
        unsigned char bit_floor_7 : 1;
        unsigned char bit_floor_8 : 1;

        unsigned char reserve[7];
    } msg_key_board_recv_s_t;

    typedef struct
    {

        /***********************/
        unsigned char bit_door_open : 1;
        unsigned char bit_door_close : 1;
        unsigned char bit_door_hold : 1;
        unsigned char bit_fans : 1;
        unsigned char bit_light : 1;
        unsigned char bit_reserve : 3;

        unsigned char delete_floor;

        unsigned char bit_floor_1 : 1;
        unsigned char bit_floor_2 : 1;
        unsigned char bit_floor_3 : 1;
        unsigned char bit_floor_4 : 1;
        unsigned char bit_floor_5 : 1;
        unsigned char bit_floor_6 : 1;
        unsigned char bit_floor_7 : 1;
        unsigned char bit_floor_8 : 1;

        unsigned char reserve[7];
    } msg_key_board_reply_s_t;

    enum  _key_display
    {
        min = 0x00,
        floor_1,
        floor_2,
        floor_3,
        floor_4,
        floor_5,
        floor_6,
        max,
    } ;

    typedef struct
    {
        /* data */
        enum _key_display dis_foor;      //按钮楼层
        
        unsigned char upload_status;    //上报状态
        
        unsigned char registered;          //是否按下

        unsigned char pressed;       //是否登记
        
        unsigned int pressed_tick;        //按下时间，系统tick
        

        bool enable;                    //按钮是否启用，根据不同拨码，配置启动状态
    } floor_map_s;

    /*
     * 内呼板相关信息的结构
     */
    typedef struct
    {
        _version InCall_HW_version;        // 内呼板硬件版本
        _version InCall_SF_version;        // 内呼板软件版本
        _version InCall_board_pro_version; // 内呼板协议版本号
        unsigned char addr_485;            // 内呼板总线地址
        unsigned char CPUID[12];           // cpu id
        unsigned char reboot;
        unsigned int RCC_CSR; // 重启原因
        key_board_status_s_t key_event;
        floor_map_s floor_key[16];
        unsigned char floor_count;
        
        unsigned char delete_floor;
        unsigned int delete_floor_start_tick;
        unsigned short hc595_dis_val;
        unsigned short key_checked_val;
        unsigned char in_pressed_status;
        int work_mode;
        unsigned short last_keyPad_val;

    } Type_InCall_info;

#pragma pack()

    Type_InCall_info *get_InCall_info(void);


#ifdef __cplusplus
}
#endif

#endif
